<?php

namespace App\Admin\Actions\UserAction;

use App\Models\GoldRound;
use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;

class SyncUserCache extends RowAction
{
    public $name = '同步会员缓存';

	public function dialog()
	{
		$this->confirm('确定同步当前会员信息缓存');
	}

    public function handle(Model $user)
    {
    	/*if (GoldRound::hasAnyLock()) {
		    return $this->response()->error('活动中不可同步')->refresh();
	    }*/

	    $user->fresh()->addToCache();

	    return $this->response()->success('同步成功')->refresh();
    }
}
